<?php
class Pageley_Checks {
    private function __construct() { }
    
    public static function parameterNotNull($parameter, $name, $type = null) {
        if($parameter === null) {
            throw new Pageley_Util_IllegalArgumentException($name . " cannot be null.");
        } else if($type !== null && !is_a($parameter, $type)) {
            throw new Pageley_Util_IllegalArgumentException($name . " should be an instance of " . $type . " but was: " . get_class($parameter) . ".");
        }
    }
    
    public static function propertyBeenSet($property, $name, $type = null) {
        if($property === null) {
            throw new Pageley_Util_IllegalStateException($name . " has not been set.");
        } else if($type !== null && !is_a($property, $type)) {
            throw new Pageley_Util_IllegalArgumentException($name . " should be an instance of " . $type . " but was: " . get_class($property) . ".");
        }
    }
}